package com.zx.mes.hyl.upms.controller;


import com.zx.mes.hyl.upms.pagemodel.User;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;


/**
 * @author hyl
 * @date 2017-12-1
 */
@Controller
public class LoginController{


    @RequestMapping({"/","/index"})
    public String index(){
        return"main";
    }

    @RequestMapping("/login")
    public String login(){
        return"login";
    }

    @RequestMapping(value="/ajaxLogin")
    public String ajaxLogin(User user, HttpServletRequest request) {

        UsernamePasswordToken token=new UsernamePasswordToken(user.getName(),user.getPwd());
        SecurityUtils.getSubject().login(token);
        return "";
    }

    @RequestMapping("/main")
    public String main(){
        return "main";
    }


}
